package cn.webestar.scms.user.svcapi;

import cn.webestar.scms.commons.R;
import cn.webestar.scms.commons.api.PageVO;
import cn.webestar.scms.microsvc.controller.BaseController;
import cn.webestar.scms.user.api.RoleApi;
import cn.webestar.scms.user.api.dto.Role.*;
import cn.webestar.scms.user.entity.Role;
import cn.webestar.scms.user.service.RoleService;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 角色
 */
@RestController
@RequestMapping("/svcapi/Role")
public class RoleSvcController extends BaseController<Role, Long> implements RoleApi {

    @Autowired
    private RoleService service;

    @Override
    public IService<Role> getService() {
        return service;
    }

    @Override
    @PostMapping("/delete")
    public R<Boolean> delete(@RequestParam("id") Long id) {
        return super._delete(id);
    }

    @Override
    @PostMapping("/findById")
    public R<Role> findById(@RequestParam("id") Long id) {
        return super._findById(id);
    }

    @Override
    @PostMapping("/findByIds")
    public R<Map<Long, Role>> findByIds(@RequestBody Set<Long> ids) {
        return super._findByIds(ids);
    }

    @Override
    @PostMapping("/create")
    public R<Role> create(@RequestBody RoleCreateDTO body) {
        return super._create(body);
    }

    @Override
    @PostMapping("/update")
    public R<Role> update(@RequestBody RoleUpdateDTO body) {
        return super._update(body);
    }

    @Override
    @PostMapping("/page")
    public R<PageVO<Role>> page(@RequestBody RolePageDTO body) {
        return super._page(body);
    }

    @Override
    @PostMapping("/findOne")
    public R<Role> findOne(@RequestBody RoleSimpleDTO body) {
        return super._findOne(body);
    }

    @Override
    @PostMapping("/limitList")
    public R<List<Role>> limitList(@RequestBody RoleLimitDTO body) {
        return super._limitList(body);
    }

    @Override
    @PostMapping("/findByEmpId")
    public R<List<Role>> findByEmpId(@RequestParam("empId") Long empId) {
        return R.success(this.service.findByEmpId(empId));
    }

}
